
#ifndef DEBUG_H
#define DEBUG_H

#define DEBUGLOG_VERSION "0.1.1"

#include <stdio.h>


#ifdef X86
#define log_debug(fmt, ...)      syslog(LOG_DEBUG, fmt, ##__VA_ARGS__)
#define log_info(fmt, ...)       syslog(LOG_INFO, fmt, ##__VA_ARGS__)
#define log_notice(fmt, ...)     syslog(LOG_NOTICE, fmt, ##__VA_ARGS__)
#define log_warning(fmt, ...)    syslog(LOG_WARNING, fmt, ##__VA_ARGS__)
#define log_error(fmt, ...)      syslog(LOG_ERR, fmt, ##__VA_ARGS__)
#define log_crit(fmt, ...)       syslog(LOG_CRIT, fmt, ##__VA_ARGS__)
#define log_alert(fmt, ...)      syslog(LOG_ALERT, fmt, ##__VA_ARGS__)
#define log_emerge(fmt, ...)     syslog(LOG_EMERG, fmt, ##__VA_ARGS__)
#else


#define FATAL      1
#define ALARM      2
#define ERROR      3
#define WARN       4
#define INFO       5
#define DEBUG      6

#define LOG_PRINT_LEVEL INFO
#if 1

#define MY_LOG(level, fmt, args...)  do{  \
    if((LOG_PRINT_LEVEL >= level)){  \
        printf("[%s]:", __FUNCTION__); \
        printf(fmt, ##args); \
        printf("\n"); \
    }  \
}while(0)
#define MY_PRINTF(level, fmt, args...)  do{  \
        if((LOG_PRINT_LEVEL >= level)){  \
            printf(fmt, ##args); \
        }  \
    }while(0)

#define log_debug(fmt, ...)      MY_LOG(DEBUG, fmt, ##__VA_ARGS__)
#define log_info(fmt, ...)       MY_LOG(INFO, fmt, ##__VA_ARGS__)
#define log_notice(fmt, ...)     MY_LOG(INFO, fmt, ##__VA_ARGS__)
#define log_warning(fmt, ...)    MY_LOG(WARN, fmt, ##__VA_ARGS__)
#define log_error(fmt, ...)      MY_LOG(ERROR, fmt, ##__VA_ARGS__)
#define log_crit(fmt, ...)       MY_LOG(ERROR, fmt, ##__VA_ARGS__)
#define log_alert(fmt, ...)      MY_LOG(ERROR, fmt, ##__VA_ARGS__)
#define log_emerge(fmt, ...)     MY_LOG(ERROR, fmt, ##__VA_ARGS__)

#define log_printf(fmt, ...)       MY_PRINTF(INFO, fmt, ##__VA_ARGS__)

#else
#define NONE                 "\e[0m"
#define BLACK                "\e[0;30m"
#define L_BLACK              "\e[1;30m"
#define RED                  "\e[0;31m"
#define L_RED                "\e[1;31m"
#define GREEN                "\e[0;32m"
#define L_GREEN              "\e[1;32m"
#define BROWN                "\e[0;33m"
#define YELLOW               "\e[1;33m"
#define BLUE                 "\e[0;34m"
#define L_BLUE               "\e[1;34m"
#define PURPLE               "\e[0;35m"
#define L_PURPLE             "\e[1;35m"
#define CYAN                 "\e[0;36m"
#define L_CYAN               "\e[1;36m"
#define GRAY                 "\e[0;37m"
#define WHITE                "\e[1;37m"
	
#define BOLD                 "\e[1m"
#define UNDERLINE            "\e[4m"
#define BLINK                "\e[5m"
#define REVERSE              "\e[7m"
#define HIDE                 "\e[8m"
#define CLEAR                "\e[2J"
#define CLRLINE              "\r\e[K" //or "\e[1K\r"
	
	
#define log_info(fmt, args...) do{  \
        if((LOG_PRINT_LEVEL >= INFO)){  \
		printf(GREEN"%d [info]:[%s]:"NONE, (int)time((time_t*)NULL),__FUNCTION__);  \
		printf(fmt, ##args);  \
		printf("\n"); \
        } \
		}while(0);

#define log_warning(fmt, args...) do{  \
        if((LOG_PRINT_LEVEL >= WARN)){  \
		printf(YELLOW"%d [warn]:[%s]:"NONE,(int)(time((time_t*)NULL)), __FUNCTION__);  \
		printf(fmt, ##args);  \
		printf("\n"); \
        } \
		}while(0);

#define log_error(fmt, args...) do{  \
        if((LOG_PRINT_LEVEL >= ERROR)){  \
		printf(RED"%d [erro]:[%s]:"NONE, (int)time((time_t*)NULL),__FUNCTION__);  \
		printf(fmt, ##args);  \
		printf("\n"); \
        } \
		}while(0);
#endif
#endif
#endif
